/**
 * 提交充值
 */
function submitForm() {
    $("body").trigger("click");

    var phoneNum = $("#phoneNumber").val().trim().replace(" ", "").replace(" ", "");
    var dimension = $("#hiddenDimension").val();
    var selectedProduct = $("input[name='flow_type']:checked").val();

    if (!checkPhoneNum(phoneNum)) {
        alert("请输入正确的手机号码！谢谢");
        return;
    }
    if (isNull(dimension)) {
        alert("请选择充值产品！谢谢");
        return;
    }

    $("#submit_form").attr("disabled", "disabled");
    setTimeout(function() {
        $("#submit_form").removeAttr("disabled");
    }, 3000);

    var url = PAY_PATH + "/145";
    var data = {
        "hiddenAccountNo" : phoneNum,
        "hiddenDimension" : dimension,
        "hiddenProduct" : selectedProduct,
        "userId":userId,
        "memberId":memberId
    }
    toPay(url,data);

}
/**
 * 切换国内流量与省内流量
 */
function changeProduct() {
    var selectedVal = $("input[name='flow_type']:checked").val();
//	$("#hiddenProduct").val(selectedVal);
    checkPhoneNumber();
}
/**
 * 验证手机号并获取归属地及产品售价信息
 */
function checkPhoneNumber(event) {
    var inputVal = $("#phoneNumber").val();
    var product = $("input[name='flow_type']:checked").val();
    if (inputVal.length != 0) {
        var oEvent = event || window.event;
        if (oEvent.keyCode != 8) {
            if (inputVal.length == 3 || inputVal.length == 8) {
                $("#phoneNumber").val(inputVal + " ");
            }
        }
        if (oEvent.keyCode == 8) {
            if (inputVal.length == 3 || inputVal.length == 8) {
                inputVal = inputVal.substring(0, inputVal.length - 1);
                $("#phoneNumber").val(inputVal);
            }
        }
        var phoneNum = inputVal.replace(" ", "").replace(" ", "");
        if (!checkPhoneNum(phoneNum)) {
            $("#PhoneInfo").text("");
            return;
        }
        $('#phoneNumber').blur();
        $("body").trigger("click");
        $
            .ajax({
                type : "GET",
                url : OPEN_PATH + "/145/product",
                dataType : 'json', // 返回json格式数据
                data : {
                    "num" : phoneNum,
                    "pt" : product
                }, // 数据
                cache : false,
                error : function() {
                    $("#PhoneInfo").text("查询归属地失败");
                    var str = newNoProItem();
                    $("#PriceTag_Div").empty();
                    $("#PriceTag_Div").html(str);
                },
                success : function(msg) {
                    //刷新面额
                    $("#hiddenDimension").val("");
                    //重新加载数据
                    var result = msg;
                    var local = result.attr;
                    $("#PhoneInfo").html(local);
                    var productsHtml = "";
                    json = eval(result.products);
                    if (isNull(json) || json.length == 0) {
                        productsHtml = newNoProItem();
                    } else {
                        for (var i = json.length - 1; i >= 0; i--) {
                            productsHtml += newProItem(json[i].dimension,json[i].sale,product);
                        }
                    }
                    $("#PriceTag_Div").html(productsHtml);
                },
                beforeSend : function() {
                    $("#loadingToast").show();
                },
                complete : function() {
                    $("#loadingToast").hide();
                }
            });
    }

}
function noteToggle(id){
    $("#" + id).toggle();
}